#include <stdio.h>  
  
int month[12] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304};  
int main(int argc, char **argv) {  
    int n, y, m, d, yy, mm, dd, x;  
    if (scanf("%d", &n));  
  
    for (int i = 0; i < n; i++) {  
        if (scanf("%d%d%d", &y, &m, &d));  
        yy = y;  
        mm = m;  
        dd = d;  
        if (y % 100 != 0 || (y % 400 == 0))  
            x = (y - 1900) % 4 == 0 ? m <= 2 ? -1 : 0 : 0;  
        else  
            x = 0;  
        m = month[m];  
        x += (y - 1988) / 4 - (y - 1900) / 100 + (y - 1600) / 400;  
        //printf("%d %d\n", x, d);  
        int dowhat = (y - 1990) * 365 + m + d + x - 1;  
        //printf("days = %d\n", dowhat);  
        dowhat %= 5;  
        if (dowhat < 3)  
            printf("He was fishing on %d.%d.%d\n", yy, mm, dd);  
        else  
            printf("He was basking on %d.%d.%d\n", yy, mm, dd);  
    }  
    return 0;  
}  